<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
	xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout">
<div th:fragment="header">
	<div class="head-top">
		<div class="head-top-l" id="xtsj"></div>
		<div class="head-top-r">
			<div class="green-battery">
				<div class="head-top-rl" id="mkq"></div>
				<div class="head-top-rm">
					<div id="jdt" style="width: 0%"></div>
				</div>
				<div class="head-top-rr"></div>
			</div>
		</div>
	</div>
	<script th:inline="javascript">
		/*<![CDATA[*/
		//获得当前时间,刻度为一千分一秒
		var initializationTime = (new Date()).getTime();

		function Appendzero(obj) {
			if (obj < 10)
				return "0" + obj;
			else
				return obj;
		}
		function showLeftTime() {
			var now = new Date();
			var hours = now.getHours();
			var minutes = now.getMinutes();
			$("#xtsj").text(Appendzero(hours) + ":" + Appendzero(minutes));
		}
		//一秒刷新一次显示时间
		setInterval(showLeftTime, 1000);

		//电量
		$(function() {
			heartAjax();
			setInterval(heartAjax, 1000*20);
			// 电量
			function heartAjax() {
				$.ajax({
					type : "post",
					url : "/powTechysky",
					dataType : "json",
					success : function(data) {
						
						$("#mkq").text(data + "%");
						$("#jdt").css("width", data + "%");
						if(data<=10){
							$(".green-battery").addClass("red-battery");
						}
						
						
			/* 			if (data.code==200) {
							$("#mkq").text(data.msg + "%");
							$("#jdt").css("width", data.msg + "%");
							if(data.msg<=10){
								$(".green-battery").addClass("red-battery");
							}
						}else{
							alert("guoq")
						} */
					},
					error : function(msg) {

					}

				});
			}
		});
		/*]]>*/
	</script>
</div>

</html>